package com.xcity.game.battle.pve.employee.impl;

import com.xcity.game.battle.pve.PlayerBattler;
import com.xcity.game.battle.pve.employee.EmployeeSkillBattleContext;
import com.xcity.game.employee.skill.EmployeeSkill;

//谈判中气势值低于{0=20#0}%时获得一个防御护盾，抵抗{1=3#0}次伤害后消失，每局只能生效{2=1#0}次。
public class DEFENSE_SHIELD_BUFF_CONTEXT extends EmployeeSkillBattleContext {

	private boolean valid;
	private int sumOfValid;
	
	public DEFENSE_SHIELD_BUFF_CONTEXT(PlayerBattler player, EmployeeSkill ref) {
		super(player, ref);
	}

	@Override
	public boolean trigger() {
		if (!valid
				&& sumOfValid < ref.getTemplate().getInitVal(2)
				&& player.getHp() < player.getMaxHp() * ref.getTemplate().getInitVal(0) / 100) {
			valid = true;
			triggeredTimes = 0;
		}
		if (valid) {
			if (++triggeredTimes >= ref.getTemplate().getInitVal(1)) {
				valid = false;
				sumOfValid++;
			}
			return true;
		}
		return false;
	}

}
